<?php

/**
 * 经验
 * Class exp
 */
class exp {

    public static $exp_arr = [
        'member' => [
            1 => ['exp' => 0, 'cn' => '孤陋寡闻'],
            2 => ['exp' => 200, 'cn' => '浅见寡识'],
            3 => ['exp' => 3000, 'cn' => '出类拔萃'],
            4 => ['exp' => 10000, 'cn' => '才高八斗'],
            5 => ['exp' => 30000, 'cn' => '雄才盖世'],
            6 => ['exp' => 900000, 'cn' => '未知未知'],
        ],
        'teacher' => [
            1 => ['exp' => 0, 'cn' => '平易近人'],
            2 => ['exp' => 200, 'cn' => '虚怀若谷'],
            3 => ['exp' => 500, 'cn' => '满腹经纶'],
            4 => ['exp' => 3000, 'cn' => '德高望重'],
            5 => ['exp' => 10000, 'cn' => '国士无双'],
            6 => ['exp' => 100000, 'cn' => '未知未知'],
        ],
        'team' => [
            1 => ['exp' => 0, 'cn' => '人文荟萃'],
            2 => ['exp' => 200, 'cn' => '人杰地灵'],
            3 => ['exp' => 500, 'cn' => '学养深厚'],
            4 => ['exp' => 3000, 'cn' => '百年树人'],
            5 => ['exp' => 10000, 'cn' => '万世师表'],
            6 => ['exp' => 100000, 'cn' => '未知未知'],
        ],
    ];

    public static function lv($exp, $type = 'member') {
        $exp_arr = self::$exp_arr[$type];

        foreach ($exp_arr as $k => $v) {
            if ($exp >= $v['exp']) {
                $lv = $k;
                continue;
            } else {
                return $lv;
            }
        }
    }

    public static function cn($exp, $type = 'member') {
        $exp_arr = self::$exp_arr[$type];

        foreach ($exp_arr as $k => $v) {
            if ($exp >= $v['exp']) {
                $cn = $v['cn'];
                continue;
            } else {
                return $cn;
            }
        }
    }

    //还没用
    public static function lvp($exp, $type = 'member', $v = false) {
        $exp_arr = self::$exp_arr[$type];
        $exp1 = 0;
        $exp2 = 1;

        foreach ($exp_arr as $k => $v) {
            if ($exp >= $v['exp']) {
                $exp1 = $v['exp'];
                continue;
            } else {
                $exp2 = $v['exp'];
                break;
            }
        }

        $bfb = ($exp - $exp1) / ($exp2 - $exp1) * 100;
        return (int)$bfb + 1;
    }
}

?>